home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 23 / CU Amiga - Super CD-ROM 23 (June 1998).iso / CreatingGames / Utilities / C / ASAP / filehandle.h < prev    next >
Encoding:
C/C++ Source or Header  |  2006-09-08  |  8.5 KB  |  227 lines

  1. /*****************************************************************************
  2.  *                                                                           *
  3.  * ASAP - Amiga Software Authoring Platform                                  *
  4.  *                                                                           *
  5.  * Written by Laurie Perrin                                                  *
  6.  *                                                                           *
  7.  * AFileHandle wrapper class                                                 *
  8.  *                                                                           *
  9.  *****************************************************************************/
  10.  
  11. #ifndef ASAP_FileHandle_H
  12. #define ASAP_FileHandle_H
  13.  
  14. #include <New.h>
  15.  
  16. extern "C"
  17. {
  18.  #include <Proto/DOS.h>
  19. }
  20.  
  21. class AFileLock;
  22.  
  23. class AFileHandle : public FileHandle
  24. {
  25.  public:
  26.  inline LONG Close();
  27.  inline void operator delete (void *);
  28.  inline AFileLock * DupLockFromFH();
  29.  inline BOOL ExamineFH(FileInfoBlock * fib);
  30.  inline LONG FGetC();
  31.  inline STRPTR FGets(STRPTR buf, unsigned long buflen);
  32.  inline LONG FPrintf(STRPTR format, LONG arg1 = 0, ...);
  33.  inline LONG FPutC(long ch);
  34.  inline LONG FPuts(STRPTR str);
  35.  inline LONG FRead(APTR block, unsigned long blocklen, unsigned long number);
  36.  inline LONG FWrite(APTR block, unsigned long blocklen, unsigned long number);
  37.  inline void FWritef(STRPTR format, LONG = 0, ...);
  38.  inline LONG Flush();
  39.  inline BPTR InternalLoadSeg(BPTR table, LONG * funcarray, LONG * stack);
  40.  inline LONG IsInteractive();
  41.  inline BOOL LockRecord(unsigned long offset, unsigned long length, unsigned long mode, unsigned long timeout);
  42.  inline LONG NameFromFH(STRPTR buffer, long len);
  43.  inline static AFileHandle * Open(STRPTR name, long accessMode);
  44.  inline void * operator new(size_t, STRPTR name, long accessMode);
  45.  inline AFileLock * ParentOfFH();
  46.  inline LONG Read(APTR buffer, long length);
  47.  inline LONG Seek(long position, long offset);
  48.  inline AFileHandle * SelectInput();
  49.  inline AFileHandle * SelectOutput();
  50.  inline LONG SetFileSize(long pos, long mode);
  51.  inline LONG SetMode(long mode);
  52.  inline LONG SetVBuf(STRPTR buff, long type, long size);
  53.  inline LONG UnGetC(long character);
  54.  inline BOOL UnLockRecord(unsigned long offset, unsigned long length);
  55.  inline LONG VFPrintf(STRPTR format, APTR argarray);
  56.  inline void VFWritef(STRPTR format, LONG * argarray);
  57.  inline LONG WaitForChar(long timeout);
  58.  inline LONG Write(APTR buffer, long length);
  59. };
  60. //----------------------------------------------------------------------------
  61. LONG AFileHandle::Close ()
  62. {
  63.  return ::Close((BPTR) this);
  64. }
  65. //----------------------------------------------------------------------------
  66. void AFileHandle::operator delete (void *file)
  67. {
  68.  ((AFileHandle *) file)->Close();
  69. }
  70. //----------------------------------------------------------------------------
  71. AFileLock * AFileHandle::DupLockFromFH ()
  72. {
  73.  return (AFileLock *) ::DupLockFromFH((BPTR) this);
  74. }
  75. //----------------------------------------------------------------------------
  76. BOOL AFileHandle::ExamineFH (FileInfoBlock * fib)
  77. {
  78.  return ::ExamineFH((BPTR) this, fib);
  79. }
  80. //----------------------------------------------------------------------------
  81. LONG AFileHandle::FGetC ()
  82. {
  83.  return ::FGetC((BPTR) this);
  84. }
  85. //----------------------------------------------------------------------------
  86. STRPTR AFileHandle::FGets (STRPTR buf, unsigned long buflen)
  87. {
  88.  return ::FGets((BPTR) this, buf, buflen);
  89. }
  90. //----------------------------------------------------------------------------
  91. LONG AFileHandle::FPrintf (STRPTR format, LONG arg1, ...)
  92. {
  93.  return AFileHandle::VFPrintf(format, &arg1);
  94. }
  95. //----------------------------------------------------------------------------
  96. LONG AFileHandle::FPutC (long ch)
  97. {
  98.  return ::FPutC((BPTR) this, ch);
  99. }
  100. //----------------------------------------------------------------------------
  101. LONG AFileHandle::FPuts (STRPTR str)
  102. {
  103.  return ::FPuts((BPTR) this, str);
  104. }
  105. //----------------------------------------------------------------------------
  106. LONG AFileHandle::FRead (APTR block, unsigned long blocklen, unsigned long number)
  107. {
  108.  return ::FRead((BPTR) this, block, blocklen, number);
  109. }
  110. //----------------------------------------------------------------------------
  111. LONG AFileHandle::FWrite (APTR block, unsigned long blocklen, unsigned long number)
  112. {
  113.  return ::FWrite((BPTR) this, block, blocklen, number);
  114. }
  115. //----------------------------------------------------------------------------
  116. void AFileHandle::FWritef (STRPTR format, LONG arg1, ...)
  117. {
  118.  AFileHandle::VFWritef(format, &arg1);
  119. }
  120. //----------------------------------------------------------------------------
  121. LONG AFileHandle::Flush ()
  122. {
  123.  return ::Flush((BPTR) this);
  124. }
  125. //----------------------------------------------------------------------------
  126. BPTR AFileHandle::InternalLoadSeg (BPTR table, LONG * funcarray, LONG * stack)
  127. {
  128.  return ::InternalLoadSeg((BPTR) this, table, funcarray, stack);
  129. }
  130. //----------------------------------------------------------------------------
  131. LONG AFileHandle::IsInteractive ()
  132. {
  133.  return ::IsInteractive((BPTR) this);
  134. }
  135. //----------------------------------------------------------------------------
  136. BOOL AFileHandle::LockRecord (unsigned long offset, unsigned long length, unsigned long mode, unsigned long timeout)
  137. {
  138.  return ::LockRecord((BPTR) this, offset, length, mode, timeout);
  139. }
  140. //----------------------------------------------------------------------------
  141. LONG AFileHandle::NameFromFH (STRPTR buffer, long len)
  142. {
  143.  return ::NameFromFH((BPTR) this, buffer, len);
  144. }
  145. //----------------------------------------------------------------------------
  146. AFileHandle * AFileHandle::Open (STRPTR name, long accessMode)
  147. {
  148.  return (AFileHandle *) ::Open(name, accessMode);
  149. }
  150. //----------------------------------------------------------------------------
  151. void * AFileHandle::operator new (size_t, STRPTR name, long accessMode)
  152. {
  153.  return AFileHandle::Open(name, accessMode);
  154. }
  155. //----------------------------------------------------------------------------
  156. AFileLock * AFileHandle::ParentOfFH ()
  157. {
  158.  return (AFileLock *) ::ParentOfFH((BPTR) this);
  159. }
  160. //----------------------------------------------------------------------------
  161. LONG AFileHandle::Read (APTR buffer, long length)
  162. {
  163.  return ::Read((BPTR) this, buffer, length);
  164. }
  165. //----------------------------------------------------------------------------
  166. LONG AFileHandle::Seek (long position, long offset)
  167. {
  168.  return ::Seek((BPTR) this, position, offset);
  169. }
  170. //----------------------------------------------------------------------------
  171. AFileHandle * AFileHandle::SelectInput ()
  172. {
  173.  return (AFileHandle *) ::SelectInput((BPTR) this);
  174. }
  175. //----------------------------------------------------------------------------
  176. AFileHandle * AFileHandle::SelectOutput ()
  177. {
  178.  return (AFileHandle *) ::SelectOutput((BPTR) this);
  179. }
  180. //----------------------------------------------------------------------------
  181. LONG AFileHandle::SetFileSize (long pos, long mode)
  182. {
  183.  return ::SetFileSize((BPTR) this, pos, mode);
  184. }
  185. //----------------------------------------------------------------------------
  186. LONG AFileHandle::SetMode (long mode)
  187. {
  188.  return ::SetMode((BPTR) this, mode);
  189. }
  190. //----------------------------------------------------------------------------
  191. LONG AFileHandle::SetVBuf (STRPTR buff, long type, long size)
  192. {
  193.  return ::SetVBuf((BPTR) this, buff, type, size);
  194. }
  195. //----------------------------------------------------------------------------
  196. LONG AFileHandle::UnGetC (long character)
  197. {
  198.  return ::UnGetC((BPTR) this, character);
  199. }
  200. //----------------------------------------------------------------------------
  201. BOOL AFileHandle::UnLockRecord (unsigned long offset, unsigned long length)
  202. {
  203.  return ::UnLockRecord((BPTR) this, offset, length);
  204. }
  205. //----------------------------------------------------------------------------
  206. LONG AFileHandle::VFPrintf (STRPTR format, APTR argarray)
  207. {
  208.  return ::VFPrintf((BPTR) this, format, argarray);
  209. }
  210. //----------------------------------------------------------------------------
  211. void AFileHandle::VFWritef (STRPTR format, LONG * argarray)
  212. {
  213.  ::VFWritef((BPTR) this, format, argarray);
  214. }
  215. //----------------------------------------------------------------------------
  216. LONG AFileHandle::WaitForChar (long timeout)
  217. {
  218.  return ::WaitForChar((BPTR) this, timeout);
  219. }
  220. //----------------------------------------------------------------------------
  221. LONG AFileHandle::Write (APTR buffer, long length)
  222. {
  223.  return ::Write((BPTR) this, buffer, length);
  224. }
  225.  
  226. #endif
  227.